package com.hbnu.tangyalu;

import java.io.IOException;
import java.io.PipedOutputStream;

public class Send implements Runnable{
    private PipedOutputStream pipedOutputStream;

    public Send() {
        this.pipedOutputStream=new PipedOutputStream();
    }

    public PipedOutputStream getPipedOutputStream() {
        return pipedOutputStream;
    }

    @Override
    public void run() {
        try {
            String content="管道传输数据";
            byte[] bytes=content.getBytes();
            pipedOutputStream.write(bytes);
            System.out.println("发送数据"+content);
        }
        catch (IOException e){
            e.printStackTrace();
        }
        finally {
            try {
                if (pipedOutputStream!=null){
                    pipedOutputStream.close();
                }
            }catch (IOException e){
                e.printStackTrace();
            }

        }
    }
}
